package com.example.demo01minio.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName:MPConfig
 * Package:com.example.demo01minio.config
 * Description:
 *
 * @Author:helei
 * @Create:2024/8/27 - 15:37
 */
@Configuration
public class MPConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //创建mybatis的mp拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //创建mp内部自己的 分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setDbType(DbType.MYSQL); //设置要操作的数据库类型，默认mysql
        paginationInnerInterceptor.setOverflow(true); //设置分页合理化，如果超过的页码超过总页码 返回最后一页
        //将分页拦截器 注册给MybatisPlusInterceptor拦截器
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        //返回MybatisPlusInterceptor 注入到ioc容器中
        return interceptor;
    }

}
